<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>绑定页面</title>
    <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport"/>
    <meta content="yes" name="apple-mobile-web-app-capable"/>
    <meta content="black" name="apple-mobile-web-app-status-bar-style"/>
    <meta content="telephone=no" name="format-detection"/>
    <link href="{{url('css/style_login.css?v=1.1')}}" type="text/css" rel="stylesheet"/>
    <script src="{{url('js/jquery.js')}}" type="text/javascript"></script>
    <script src="{{url('js/layer.m.js')}}"></script>
</head>
<body>

<!--/start-login-one-->
<h1>泛娱乐测试平台</h1>

<div class="login">
    <div class="ribbon-wrapper h2 ribbon-red">
        <div class="ribbon-front">
            <h2>会员身份绑定</h2>
        </div>
        <div class="ribbon-edge-topleft2"></div>
        <div class="ribbon-edge-bottomleft"></div>
    </div>
    {{--action="{{url('/wx/login')}}" method="post"--}}
    <form>
        <ul>
            <li>
                <input type="text" name="userid" class="userid" placeholder="请输入身份证号" value=""><a href="#" class=" icon user"></a>
            </li>
            <li>
                <input type="text" name="name"  class="name"  placeholder="请输入姓名" value=""><a href="#" class=" icon name"></a>
            </li>
            <li>
                <input type="text" name="phonenum" class="phonenum" placeholder="请输入手机号" value=""><a href="#" class=" icon phone"></a>
            </li>
            <li class="box_yz">
                <input type="yz" name="code"  class="code" placeholder="输入验证码" value="">
            </li>
            <div class="get_yz">
                <input type="button"  value="获取验证码" id="btn" >
            </div>
        </ul>
        <div class="submit">
            <input type="button" class="buttons" value="绑  定">
        </div>
    </form>

</div>

<script>
    $(function () {
        $('.buttons').click(function(){
            $('.buttons').attr("disabled", true);
            var userid= $('.userid').val();
            var name=$('.name').val();
            var phonenum=$('.phonenum').val();
            var code=$('.code').val();
            if(userid==''){
                layer.open({
                    title: [
                        '提示',
                    ],
                    content: '请输入身份证!'
                });
                return false;
            }
            if(name==''){
                layer.open({
                    title: [
                        '提示',
                    ],
                    content: '请输入姓名'
                });
                return false;
            }
            if(phonenum==''){
                layer.open({
                    title: [
                        '提示',
                    ],
                    content: '请输入手机号！'
                });
                return false;
            }
            if(code==''){
                layer.open({
                    title: [
                        '提示',
                    ],
                    content: '请输入验证码！'
                });
                return false;
            }
            /*alert(code);
            return false;*/
            $.post("/wx/login",{userid:userid,name:name,phonenum:phonenum,code:code},function(result){
                if(result.errcode==0){
                    window.location.href=result.data;
                }else{
                    layer.open({
                        title: [
                            '提示',
                        ],
                        content: result.errmsg
                    });
                    $('.buttons').attr("disabled",false);
                }
            },"json");
        });


        var wait=60;
        function time(o) {
            if (wait == 0) {
                o.removeAttribute("disabled");
                o.value="获取验证码";
                wait = 60;
            } else {
                o.setAttribute("disabled", true);
                o.value="重新发送(" + wait + ")";
                wait--;
                setTimeout(function() {
                            time(o)
                        },
                        1000)
            }
        }
        document.getElementById("btn").onclick=function(){
            var phonenum=$('.phonenum').val();
            if(phonenum==''){
                alert('手机号不为空!');
                return false;
            }
            $.get("/wx/getcode",{phonenum:phonenum},function(result){
                if(result.ret>0){
                    //window.location.href=result.data;
                    time(document.getElementById("btn"));
                }else{
                    layer.open({
                        title: [
                            '提示',
                        ],
                        content: "获取失败:"+result.ret
                    });
                }
            },"json");


            //
        }
    });
</script>
</body>
</html>
